package cn.wolfcode.wolf2w.web.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.repository.StrategyCatalogRepository;
import cn.wolfcode.wolf2w.repository.StrategyRepository;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
@RequestMapping("destinations")
public class DestinationsController {
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private StrategyCatalogRepository strategyCatalogRepository;

    @Autowired
    IStrategyCatalogService strategyCatalogService;

    @Autowired
    IStrategyService strategyService;

    @Autowired
    ITravelService travelService;
    @Autowired
    MongoTemplate mongoTemplate;

    @RequestMapping("search")
    @ResponseBody
    public Object search(String regionId){
        return JsonResult.success(destinationService.getDestByRegionIdForApi(regionId));
    }


    @RequestMapping("hotRegion")
    @ResponseBody
    public Object hotRegions(){
        System.out.println(regionService.queryHotRegion().toString());
        return JsonResult.success(regionService.queryHotRegion());
    }
    @RequestMapping("toasts")
    @ResponseBody
    public Object toasts(String destId){
        return JsonResult.success(destinationService.getToasts(destId));
    }
    @RequestMapping("detail")
    @ResponseBody
    public Object detail(String id){
        return JsonResult.success(destinationService.get(id));
    }

    @RequestMapping("catalogs")
    @ResponseBody
    public Object catalog(String destId){

        return JsonResult.success(strategyCatalogService.queryCatalogByDestId(destId));
    }
    @RequestMapping("strategies/viewnumTop3")
    @ResponseBody
    public Object viewnumTop3(String destId){
        return JsonResult.success(strategyService.getViewnumTop3(destId));
    }
    @RequestMapping("travels/viewnumTop3")
    @ResponseBody
    public Object travelsViewnumTop3(String destId){
        return JsonResult.success(travelService.getViewnumTop3(destId));
    }
}
